﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using System.Collections.ObjectModel;
using System.Threading.Tasks;

namespace TV_Organizer
{
    #region TVShowsConnectors

    [MetadataAttribute]
    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
    public sealed class TVShowsConnectorAttribute : ExportAttribute
    {
        public TVShowsConnectorAttribute(string serviceName)
            : base(typeof(ITVShowsConnector<TVShow>))
        {
            this.ShowsServiceName = serviceName;
        }

        public string ShowsServiceName { get; private set; }

    }

    public interface ITVShowsConnectorMetadata
    {
        string ShowsServiceName { get; }
    }

    public interface ITVShowsConnector<out T> where T : TVShow
    {
        IEnumerable<T> SearchShow(string search);
        IEnumerable<T> Shows { get; }
        Episode GetEpisode(TVShow show, int season, int episode);
    }

    #endregion

    #region TVSubtitlesConnectors

    [MetadataAttribute]
    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
    public sealed class TVSubtitlesConnectorAttribute : ExportAttribute
    {
        public TVSubtitlesConnectorAttribute(string serviceName)
            : base(typeof(ITVSubtitlesConnector))
        {
            this.SubtitlesServiceName = serviceName;
        }

        public string SubtitlesServiceName { get; private set; }
    }

    public interface ITVSubtitlesConnectorMetadata
    {
        string SubtitlesServiceName { get; }
    }

    public interface ITVSubtitlesConnector
    {
        Task<IEnumerable<Subtitles.Subtitle>> SearchSubtitlesForAsync(TVShow tvShow, Episode episode);
        Task<bool> DownloadSubtitleAsync(Subtitles.Subtitle subtitle, string filename);
    }

    #endregion
}
